package org.coderk.mybatis.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.aop.framework.AopContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.PushBuilder;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;

/**
 * @author: TanJingyu
 * @create: 2021-06-03 10:12
 **/
@RestController
@RequestMapping("/hello/2")
public class Helloooo {

    @GetMapping
    public InnerHello hello(WebRequest webRequest,
                            HttpServletRequest httpServletRequest,
                            HttpSession httpSession,
                            PushBuilder pushBuilder,
                            @RequestBody(required = false) MultipartRequest multipartRequest,
                            @RequestBody(required = false) MultipartHttpServletRequest multipartHttpServletRequest) {
        ObjectMapper objectMapper = new ObjectMapper();
        return new InnerHello(1, LocalDateTime.now(), new Date());
    }


    @NoArgsConstructor
    @AllArgsConstructor
    @Getter
    @Setter
    public static class InnerHello {
        @JsonIgnore
        private Integer id;
        //        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime endTime;
        @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
        private Date startTime;

    }
}
